package me.boot.web.common.template.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import me.boot.db.mybatis.template.SuperService;
import me.boot.db.mybatis.template.entity.Entity;
import me.boot.web.common.template.model.Result;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.io.Serializable;
import java.util.Arrays;

public interface RemoveController<
        ID extends Serializable,
        PO extends Entity<ID>,
        S extends SuperService<ID, PO>>
        extends BaseController<ID, PO, S> {

    @ApiOperation(value = "删除一条")
    @ApiOperationSupport(order = 31)
    @DeleteMapping("/remove/{id}")
    default Result<Boolean> removeById(@PathVariable("id") ID id) {
        return Result.newSuccess(getService().removeById(id));
    }

    @ApiOperation(value = "批量删除")
    @ApiOperationSupport(order = 32)
    @DeleteMapping("/remove/batch/{ids}")
    default Result<Boolean> removeByIds(@PathVariable("ids") ID[] ids) {
        return Result.newSuccess(getService().removeByIds(Arrays.asList(ids)));
    }
}
